/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.game.stepbystep;

import java.io.IOException;

/**
 *
 * @author zinin
 */
public class StateIdle extends State{

    private GameLayerManager context;
    StateIdle(GameLayerManager aThis) {
        context = aThis;
    }

    public boolean isAllowDragging() {
        return true;
    }

    public void onTapScreen(int x, int y) {
        try {
            //poition in game world coordinates
            int origx = context.gameDesign.getFatman().getX() - context.displayOriginX();
            int origy = context.gameDesign.getFatman().getY() - context.displayOriginY();
            Rect rect = new Rect(origx, origy,
                        context.gameDesign.getFatman().getWidth(),
                        context.gameDesign.getFatman().getHeight());
            rect.expand(MIDPCanvas.GRID_WIDTH * 3);
            if(rect.contains(x, y)){
                context.setState(context.STATE_CHARSELECTED);
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    public String id() {
        return "Idle";
    }
}
